Improve sensitivity handling in filechooser context menu
authorMatthias Clasen <mclasen@redhat.com>
Mon, 13 May 2013 02:17:15 +0000 (22:17 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 13 May 2013 02:17:15 +0000 (22:17 -0400)
Items that act on the selection should not be sensitive if the
selection is empty. This was already the case for the 'Copy file
location' item, but not for the 'Add bookmark' and 'Visit file'
items.
https://bugzilla.gnome.org/show_bug.cgi?id=699104

gtk/gtkfilechooserdefault.c

index c6bea3946f77246a876bf6754e6c3475e71a0766..d10fdebf6160474dc86d3b6e9a1e40dfe3fbd817 100644 (file)
@@ -1638,11 +1638,11 @@ file_list_drag_motion_cb (GtkWidget             *widget,
   return TRUE;
 }
 
-/* Sensitizes the "Copy file’s location" context menu item if there is actually
+/* Sensitizes the "Copy file’s location" and other context menu items if there is actually
  * a selection active.
  */
 static void
-check_copy_file_location_sensitivity (GtkFileChooserDefault *impl)
+check_file_list_menu_sensitivity (GtkFileChooserDefault *impl)
 {
   GtkFileChooserDefaultPrivate *priv = impl->priv;
   GtkTreeSelection *selection;
@@ -1656,6 +1656,10 @@ check_copy_file_location_sensitivity (GtkFileChooserDefault *impl)
 
   if (priv->browse_files_popup_menu_copy_file_location_item)
     gtk_widget_set_sensitive (priv->browse_files_popup_menu_copy_file_location_item, active);
+  if (priv->browse_files_popup_menu_add_shortcut_item)
+    gtk_widget_set_sensitive (priv->browse_files_popup_menu_add_shortcut_item, active);
+  if (priv->browse_files_popup_menu_visit_file_item)
+    gtk_widget_set_sensitive (priv->browse_files_popup_menu_visit_file_item, active);
 }
 
 static GtkWidget *
@@ -1727,7 +1731,7 @@ file_list_build_popup_menu (GtkFileChooserDefault *impl)
   priv->browse_files_popup_menu_size_column_item       = file_list_add_check_menu_item (impl, _("Show _Size Column"),
                                                                                         G_CALLBACK (show_size_column_toggled_cb));
 
-  check_copy_file_location_sensitivity (impl);
+  check_file_list_menu_sensitivity (impl);
 }
 
 /* Updates the popup menu for the file list, creating it if necessary */
@@ -6967,7 +6971,7 @@ list_selection_changed (GtkTreeSelection      *selection,
   path_bar_update (impl);
 
   check_preview_change (impl);
-  check_copy_file_location_sensitivity (impl);
+  check_file_list_menu_sensitivity (impl);
 
   g_signal_emit_by_name (impl, "selection-changed", 0);
 }